stack: Avoid some ugly unrefs
authorMatthias Clasen <mclasen@redhat.com>
Wed, 13 Feb 2019 13:40:13 +0000 (08:40 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 13 Feb 2019 13:40:13 +0000 (08:40 -0500)
Instead of using the list model api that forces us
to drop the ref, just work with the list we have.

gtk/gtkstack.c

index 2030e919f5c0149252be055317a7ca0d7a2d70e1..633a5ae712c17b84e92483a223ed7a943ee81f97 100644 (file)
@@ -464,8 +464,7 @@ gtk_stack_pages_is_selected (GtkSelectionModel *model,
   GtkStackPrivate *priv = gtk_stack_get_instance_private (pages->stack);
   GtkStackPage *page;
 
-  page = GTK_STACK_PAGE (g_list_model_get_item (G_LIST_MODEL (model), position));
-  g_object_unref (page);
+  page = g_list_nth_data (priv->children, position);
 
   return page == priv->visible_child;
 }
@@ -484,8 +483,7 @@ gtk_stack_pages_select_item (GtkSelectionModel *model,
   GtkStackPrivate *priv = gtk_stack_get_instance_private (pages->stack);
   GtkStackPage *page;
 
-  page = GTK_STACK_PAGE (g_list_model_get_item (G_LIST_MODEL (model), position));
-  g_object_unref (page);
+  page = g_list_nth_data (priv->children, position);
 
   set_visible_child (pages->stack, page, priv->transition_type, priv->transition_duration);